package com.yxw.yx_hotel.controller;

import com.yxw.yx_hotel.dto.*;
import com.yxw.yx_hotel.service.RoomPropertyService;
import com.yxw.yx_hotel.service.RoomRepairService;
import com.yxw.yx_hotel.vo.RoomPropertyVo;
import com.yxw.yx_hotel.vo.RoomRepairVo;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 *  宿舍报修管理
 * @author liuxin
 * @date 2024.01.18
 */
@RestController
@Api(value = "宿舍报修管理", tags = "宿舍报修管理")
@Slf4j
@RequestMapping("/api/roomRepair")
public class RoomRepairController {

    @Autowired
    private RoomRepairService roomRepairService;

    @ApiOperation(value = "新增宿舍报修信息")
    @PostMapping("/addRoomRepair")
    public BaseResult addRoomRepair(@Validated @RequestBody AddRoomRepairDto dto)  {
        roomRepairService.addRoomRepair(dto);
        return BaseResult.doSuccess(null,"新增成功");
    }

    @ApiOperation(value = "查询宿舍报修记录列表")
    @PostMapping("/pageRoomRepairList")
    public BaseResult<PageVO<RoomRepairVo>> pageRoomRepairList(@Validated @RequestBody QueryRoomRepairDto dto)  {
        PageVO<RoomRepairVo> pageVo=roomRepairService.pageRoomRepairList(dto);
        return BaseResult.doSuccess(pageVo,"查询成功");
    }

    @ApiOperation(value = "查询报修记录详情")
    @GetMapping("/getRoomRepairById")
    public BaseResult<RoomRepairVo> getRoomRepairById(@RequestParam Long repairId)  {
        RoomRepairVo vo=roomRepairService.getRoomRepairById(repairId);
        return BaseResult.doSuccess(vo,"查询成功");
    }

    @ApiOperation(value = "更新宿舍报修信息")
    @PostMapping("/updateRoomRepair")
    public BaseResult updateRoomRepair(@Validated @RequestBody UpdateRoomRepairDto dto)  {
        roomRepairService.updateRoomRepair(dto);
        return BaseResult.doSuccess(null,"更新成功");
    }
}
